<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../base.jsp" %>
<style>
	.content-wrapper{margin-left: 0px}
</style>
<body class="hold-transition skin-blue sidebar-mini">

	<div class="wrapper">
		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
			<h1>日志提取<small>规则列表</small></h1>
				<ol class="breadcrumb">
					<li><a href="javascript:;"><i class="fa fa-dashboard"></i> 首页</a></li>
					<li class="active">日志提取</li>
				</ol>
			</section>
			<!-- Main content -->
			<section class="content">
				<div class="row">
					<div class="col-xs-12">
						<div class="box">
							<div class="mailbox-controls">
							   <div class="btn-group">
							     <a href="${url }serverLog/toAdd" class="btn btn-primary">添加规则</a>
							   </div>
							 </div>
							<!-- /.box-header -->
							<div class="box-body table-responsive no-padding">
								<table class="table table-bordered" id="tbList">
									<tr>
										<th>规则名称</th>
										<th>内容</th>
										<th>操作</th>
									</tr>
								</table>
							</div>
							<!-- /.box-body -->
						</div>
						<!-- /.box -->
					</div>
				</div>
			</section>
		</div>
		<div id="result" style="display: none">${result}</div>
	</div>
	<script type="text/javascript">
	$(function () {
		var result = eval( "(" + $('#result').html() + ")" );
		var content = result.result.content;
		var html = "";
		if(content){
			for(var i=0;i<content.length;i++){
				html+='<tr><td>'+content[i].name+'</td>'
					+'<td>'+content[i].rulecontent+'</td>' 
					+'<td><a href="javascript:;" class="fa fa-edit" onclick="go('+content[i].id+')">编辑</a> | '
					+'<a href="javascript:;" class="fa fa-remove" onclick="del('+content[i].id+')">删除</a>'
					+'</td></tr>';
			}
		}
		$('#tbList').append(html);
	});
	
	function del(id){
		//信息框-例2
		layer.confirm('确认删除么？', {
		  time: 0,
		  yes: function(index){
		    layer.close(index);
		    $.post(path+'serverLog/delete',{id:id},function(data){
				if(data.result.exec){
					layer.alert('删除成功',{closeBtn:0},function(){
						location.href = path+'serverLog/list';
					});
				}else{
					layer.alert("操作失败");
				}
			});
		  }
		});
	}
	function go(id){
		location.href = path+'serverLog/toEdit?id='+id;
	}
	</script>
</body>